function onOpen(){
  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var subMenus = [];
  subMenus.push({name: "セルを選択 1", functionName: "selectCell_1"});
  subMenus.push({name: "セルを範囲選択 1", functionName: "selectCells_1"});
  
  subMenus.push(null);
  subMenus.push({name: "セルを選択 2", functionName: "selectCell_2"});
  subMenus.push({name: "セルを範囲選択 2", functionName: "selectCells_2"});
  
  subMenus.push(null);
  subMenus.push({name: "セルを選択 3", functionName: "selectCell_3"});
  subMenus.push({name: "セルを範囲選択 3", functionName: "selectCells_3"});

  subMenus.push(null);
  subMenus.push({name: "セルを選択 4", functionName: "selectCell_4"});
  subMenus.push({name: "セルを範囲選択 4", functionName: "selectCells_4"});

  subMenus.push(null);
  subMenus.push({name: "セルを相対選択", functionName: "selectRelativeCell"});
  subMenus.push({name: "セルを相対範囲選択", functionName: "selectRelativeCells"});

  subMenus.push(null);
  subMenus.push({name: "行を選択", functionName: "selectRow"});
  subMenus.push({name: "列を選択", functionName: "selectColumn"});
  subMenus.push({name: "行を範囲選択", functionName: "selectRows"});
  subMenus.push({name: "列を範囲選択", functionName: "selectColumns"});
  subMenus.push({name: "最終行を選択", functionName: "selectLastRow"});
  subMenus.push({name: "最終列を選択", functionName: "selectLastColumn"});


  ss.addMenu("拡張", subMenus);
}

function selectCell_1() {
  var mySheet = SpreadsheetApp.getActiveSheet();
  mySheet.getRange("c2").activate();
}

function selectCells_1() {
  var mySheet = SpreadsheetApp.getActiveSheet();
  mySheet.getRange("c2:c4").activate();
}

function selectCell_2() {
  var mySheet = SpreadsheetApp.getActiveSheet();
  mySheet.setActiveCell("b2");
}

function selectCells_2() {
  var mySheet = SpreadsheetApp.getActiveSheet();
  mySheet.setActiveSelection("c9:c18");
}

function selectCell_3() {
  var mySheet = SpreadsheetApp.getActiveSheet();
  mySheet.getRange(2, 3).activate();   // 引数 ( 行, 列 )
}

function selectCells_3() {
  var mySheet = SpreadsheetApp.getActiveSheet();
  mySheet.getRange(2, 3, 10).activate();   // 引数 ( 行, 列, 行数 ) or ( 行, 列, 行数, 列数 ) 
}

function selectCell_4() {
  var mySheet = SpreadsheetApp.getActiveSheet();
  mySheet.setActiveCell(mySheet.getRange(4, 5));
}

function selectCells_4() {
  var mySheet = SpreadsheetApp.getActiveSheet();
  mySheet.setActiveSelection(mySheet.getRange(4, 5, 6));
}

function selectRelativeCell() {
  var mySheet = SpreadsheetApp.getActiveSheet();
  range = mySheet.getActiveCell();
  mySheet.setActiveCell(range.offset(0, 2));
}

function selectRelativeCells() {
  var mySheet = SpreadsheetApp.getActiveSheet();
  range = mySheet.getActiveCell();
  mySheet.setActiveSelection(range.offset(0, 0, 2, 2));
}

function selectRow() {
  var mySheet = SpreadsheetApp.getActiveSheet();
  mySheet.getRange("8:8").activate();
}

function selectColumn() {
  var mySheet = SpreadsheetApp.getActiveSheet();
  mySheet.getRange("A:A").activate();
}

function selectRows() {
  var mySheet = SpreadsheetApp.getActiveSheet();
  mySheet.getRange("2:3").activate();
}

function selectColumns() {
  var mySheet = SpreadsheetApp.getActiveSheet();
  mySheet.getRange("A:B").activate();
}

function selectLastRow() {
  var mySheet = SpreadsheetApp.getActiveSheet();
  var lastCol = mySheet.getMaxColumns();
  mySheet.getRange(1, lastCol).activate();
}

function selectLastColumn() {
  var mySheet = SpreadsheetApp.getActiveSheet();
var lastRow = mySheet.getMaxRows();
  mySheet.getRange(lastRow, 1).activate();
}
function onOpen(){
  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var subMenus = [];
  subMenus.push({name: "セルを選択 1", functionName: "selectCell_1"});
  subMenus.push({name: "セルを範囲選択 1", functionName: "selectCells_1"});
  
  subMenus.push(null);
  subMenus.push({name: "セルを選択 2", functionName: "selectCell_2"});
  subMenus.push({name: "セルを範囲選択 2", functionName: "selectCells_2"});
  
  subMenus.push(null);
  subMenus.push({name: "セルを選択 3", functionName: "selectCell_3"});
  subMenus.push({name: "セルを範囲選択 3", functionName: "selectCells_3"});

  subMenus.push(null);
  subMenus.push({name: "セルを選択 4", functionName: "selectCell_4"});
  subMenus.push({name: "セルを範囲選択 4", functionName: "selectCells_4"});

  subMenus.push(null);
  subMenus.push({name: "セルを相対選択", functionName: "selectRelativeCell"});
  subMenus.push({name: "セルを相対範囲選択", functionName: "selectRelativeCells"});

  subMenus.push(null);
  subMenus.push({name: "行を選択", functionName: "selectRow"});
  subMenus.push({name: "列を選択", functionName: "selectColumn"});
  subMenus.push({name: "行を範囲選択", functionName: "selectRows"});
  subMenus.push({name: "列を範囲選択", functionName: "selectColumns"});


  ss.addMenu("拡張", subMenus);
}

function selectCell_1() {
  var mySheet = SpreadsheetApp.getActiveSheet();
  mySheet.getRange("c2").activate();
}

function selectCells_1() {
  var mySheet = SpreadsheetApp.getActiveSheet();
  mySheet.getRange("c2:c4").activate();
}

function selectCell_2() {
  var mySheet = SpreadsheetApp.getActiveSheet();
  mySheet.setActiveCell("b2");
}

function selectCells_2() {
  var mySheet = SpreadsheetApp.getActiveSheet();
  mySheet.setActiveSelection("c9:c18");
}

function selectCell_3() {
  var mySheet = SpreadsheetApp.getActiveSheet();
  mySheet.getRange(2, 3).activate();   // 引数 ( 行, 列 )
}

function selectCells_3() {
  var mySheet = SpreadsheetApp.getActiveSheet();
  mySheet.getRange(2, 3, 10).activate();   // 引数 ( 行, 列, 行数 ) or ( 行, 列, 行数, 列数 ) 
}

function selectCell_4() {
  var mySheet = SpreadsheetApp.getActiveSheet();
  mySheet.setActiveCell(mySheet.getRange(4, 5));
}

function selectCells_4() {
  var mySheet = SpreadsheetApp.getActiveSheet();
  mySheet.setActiveSelection(mySheet.getRange(4, 5, 6));
}

function selectRelativeCell() {
  var mySheet = SpreadsheetApp.getActiveSheet();
  range = mySheet.getActiveCell();
  mySheet.setActiveCell(range.offset(0, 2));
}

function selectRelativeCells() {
  var mySheet = SpreadsheetApp.getActiveSheet();
  range = mySheet.getActiveCell();
  mySheet.setActiveSelection(range.offset(0, 0, 2, 2));
}

function selectRow() {
  var mySheet = SpreadsheetApp.getActiveSheet();
  mySheet.getRange("8:8").activate();
}

function selectColumn() {
  var mySheet = SpreadsheetApp.getActiveSheet();
  mySheet.getRange("A:A").activate();
}

function selectRows() {
  var mySheet = SpreadsheetApp.getActiveSheet();
  mySheet.getRange("2:3").activate();
}

function selectColumns() {
  var mySheet = SpreadsheetApp.getActiveSheet();
  mySheet.getRange("A:B").activate();
}
